#include <iostream>
#include <vector>

using namespace std;

const int N = 2e5 + 10;

vector<int> edges[N];
bool check[N];
int n, m;

int fa[N];
int find(int x)
{
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void un(int x, int y)
{
	fa[find(x)] = find(y);
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i <= m; i++)
	{
		int u, v; cin >> u >> v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	int already_connected = 0;
	int to_release = 0;

	for(int i = 1; i <= n; i++)
	{
		++already_connected;
		if(check[i]) --to_release;
		for(auto t : edges[i])
		{
			if(t < i)
			{
				if(!(find(t) == find(i)))
				{
					un(t, i);
					--already_connected;
				}	
			}
			else
				{
					if(!check[t]) to_release++;
					check[t] = true;
				}
		}
		if(already_connected == 1) cout << to_release << endl;
		else cout << -1 << endl;
	}
	return 0;
}
